/**
 * 
 */
package org.vsg.stock.basic.service.business;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.vsg.common.biz.exception.ServiceException;
import org.vsg.stock.basic.domain.BalanceLine;
import org.vsg.stock.core.business.StockDailyKLineBO;
import org.vsg.stock.core.business.StoppingTradeDaysBO;
import org.vsg.stock.core.domain.StockDailyKLine;
import org.vsg.stock.core.indicator.coordinate.Coordinate;
import org.vsg.stock.core.indicator.coordinate.CoordinateConfiguration;
import org.vsg.stock.core.indicator.coordinate.CoordinateFactory;

/**
 * @author Bill Vison
 *
 */
public abstract class CoordinateMappingStockBalanceLineFinderBO extends
		AbstractStockBalanceLineFinderBO {
	
	
	private CoordinateConfiguration coordinateConfiguration;

	
	@Autowired
	private CoordinateFactory coordinateFactory;
	
	@Resource
	private StockDailyKLineBO stockDailyKLineBO;
	
	@Resource
	private StoppingTradeDaysBO stoppingTradeDaysBO;
	
	private Coordinate coordinate ;
	
	public CoordinateConfiguration getCoordinateConfiguration() {
		return coordinateConfiguration;
	}

	public void setCoordinateConfiguration(
			CoordinateConfiguration coordinateConfiguration) {
		this.coordinateConfiguration = coordinateConfiguration;
	}

	
	protected Coordinate getCoordinate() {
		return coordinate;
	}

	/* (non-Javadoc)
	 * @see org.vsg.stock.basic.service.business.AbstractStockBalanceLineFinderBO#scanLines(java.util.Date, int)
	 */
	@Override
	public List<BalanceLine> scanLines(Date recentDate, int aheadCycle)
			throws ServiceException {
		/**
		 * get stock kline list in reference cycle from recent date 
		 */
		stockDailyKLineBO.setStockCode( this.getStockCode() );
		List<StockDailyKLine>  stkKlineList = stockDailyKLineBO.findStockLineByCycle(recentDate, aheadCycle);

		
		coordinate = coordinateFactory.createCoordinateInstance(this.getStockCode(), coordinateConfiguration , stoppingTradeDaysBO);;
		
		
		// --- scan and mark point in to list and map ---
		scanLines( stkKlineList );
		return null;
	}
	
	
	public abstract List<BalanceLine> scanLines(List<StockDailyKLine>  stkKlineList) throws ServiceException;

}
